package cn.mdx.common.beans;

import lombok.Data;

import javax.servlet.http.HttpSession;

@Data
public class User {
    private Integer id;
    private String username;
    private Byte power;

    public static Integer getId(HttpSession session) {
        User user = (User) session.getAttribute("user");
        if(user==null) {
            return null;
        }
        return user.getId();
    }

    public static String getUsername(HttpSession session) {
        User user = (User) session.getAttribute("user");
        if(user==null) {
            return null;
        }
        return user.getUsername();
    }

    public static Byte getPower(HttpSession session) {
        User user = (User) session.getAttribute("user");
        if(user==null) {
            return null;
        }
        return user.getPower();
    }
}
